//
//  CellZheKou.m
//  SeeTheWorld
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellZheKou.h"
#import "ModeZheKou.h"
#import "PCH.pch"
#import <UIImageView+WebCache.h>


@interface CellZheKou ()

@property (nonatomic, retain)UIImageView *imageOfPhoto;
@property (nonatomic, retain)UILabel *labelOfTitle;
@property (nonatomic, retain)UILabel *labelOfBuy_price;
@property (nonatomic, retain)UILabel *labelOfLastminute_des;
@property (nonatomic, retain)UILabel *labelOfDepartureTime;


@end

@implementation CellZheKou

- (void)dealloc {
    [_imageOfPhoto release];
    [_labelOfBuy_price release];
    [_labelOfDepartureTime release];
    [_labelOfLastminute_des release];
    [_labelOfTitle release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.imageOfPhoto = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageOfPhoto];
        [_imageOfPhoto release];
        
        self.labelOfTitle = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelOfTitle];
        [_labelOfTitle release];
        self.labelOfTitle.numberOfLines = 2;
        self.labelOfTitle.font = [UIFont systemFontOfSize:15];
        
        self.labelOfDepartureTime = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelOfDepartureTime];
        [_labelOfDepartureTime release];
        self.labelOfDepartureTime.font = [UIFont systemFontOfSize:14];
        
        self.labelOfLastminute_des = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelOfLastminute_des];
        [_labelOfLastminute_des release];
        self.labelOfLastminute_des.font = [UIFont systemFontOfSize:12];
        
        self.labelOfBuy_price = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelOfBuy_price];
        [_labelOfBuy_price release];
        self.labelOfBuy_price.font = [UIFont systemFontOfSize:15];
        self.labelOfBuy_price.textColor = [UIColor redColor];
        
    }
    
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {

    self.imageOfPhoto.frame = CGRectMake(0, 0, scWIDTH, scHEIGHT / 2);
    self.labelOfTitle.frame = CGRectMake(0, scHEIGHT / 2, scWIDTH, scHEIGHT / 2 / 3 + 15);
    self.labelOfDepartureTime.frame = CGRectMake(5, scHEIGHT / 2 + scHEIGHT / 2 / 3 + 10, scWIDTH, scHEIGHT / 2 / 3);
    self.labelOfLastminute_des.frame = CGRectMake(5, scHEIGHT - 15, 30, 10);
    self.labelOfBuy_price.frame = CGRectMake(scWIDTH / 3 * 2 - 20, scHEIGHT - 20, 100, 15);

}



- (void)passModel:(ModeZheKou *)model {
    [self.imageOfPhoto sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@""]];
    self.labelOfTitle.text = model.title;
    self.labelOfDepartureTime.text = model.departureTime;
    self.labelOfLastminute_des.text = model.lastminute_des;
    self.labelOfBuy_price.text = [NSString stringWithFormat:@"%@元起", model.buy_price];
}


@end
